<template>
  <transition name="fade">
    <div class="about-alert" v-show="aboutFlag">
      <div class="content">
        <h2>关于:</h2>
        <p>这个应用可以用来追踪你选择城市的当前天气</p>
        <h2>如何使用:</h2>
        <p>
          1.点击搜索框输入你希望追踪的城市<br />
          2.在搜索结果中选中一个城市，你将获取当地最新的天气<br />
          3.点击右侧的＋号可以将追踪城市的天气情况保存在首页
        </p>
        <h2>移除城市:</h2>
        <p>如果你不想在首页关注某个城市,可以通过底部的按钮删<br />除它</p>
        <button @click="aboutFlag = false">关闭</button>
      </div>
    </div>
  </transition>
</template>

<script setup>
import { useWeatherStore } from '@/stores/weather'
import { storeToRefs } from 'pinia'

const { aboutFlag } = storeToRefs(useWeatherStore())
</script>

<style lang="scss" scoped>
.about-alert {
  display: flex;
  justify-content: center;
  position: fixed;
  top: 0px;
  width: 100%;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.3);
  z-index: 20;

  .content {
    max-width: 768px;
    height: 296px;
    padding: 16px;
    margin-top: 128px;
    background-color: white;

    h2 {
      font-size: 16px;
      font-weight: 400;
      line-height: 24px;
    }

    p {
      font-size: 12px;
      line-height: 16px;
    }

    :nth-child(2),
    :nth-child(4) {
      margin-bottom: 16px;
    }

    button {
      margin-top: 32px;
      padding: 8px 24px;
      font-size: 12px;
      line-height: 16px;
      color: white;
      background-color: rgb(0, 102, 138);
      border: none;
      cursor: pointer;
    }
  }
}

.fade-enter-active,
.fade-leave-active {
  transition: opacity 1s;
}
.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}
</style>
